<template>
  <!-- 会员档案组件 -->
  <div>
    <!-- 页面搜素栏 -->
    <div class="profile-top">
      <el-input placeholder="档案号" v-model="iputnum.fileNumber" clearable class="input-search"
        onkeyup="this.value=this.value.replace(/[, ]/g,'')">
      </el-input>
      <el-input placeholder="姓名" v-model="iputnum.memberName" clearable class="input-search"
        onkeyup="this.value=this.value.replace(/[, ]/g,'')">
      </el-input>
      <el-input placeholder="手机号" v-model="iputnum.memberPhone" clearable class="input-search"
        onkeyup="this.value=this.value.replace(/[, ]/g,'')">
      </el-input>
      <el-button type="primary" class="search-btn" @click="searchBtn(iputnum)">查询</el-button>
    </div>
    <!-- 新增按钮 -->
    <div>
      <el-button type="primary" @click="dialogTableVisible = true">新增</el-button>
    </div>
    <!--主体表单部分 -->
    <template>
      <el-table :data="
        tableData.slice((currentPage - 1) * pageSize, currentPage * pageSize)
      " @select="selectionRow" stripe style="width: 100%" :header-cell-style="{ background: 'black' }">
        <el-table-column type="selection" width="55"> </el-table-column>
        <el-table-column prop="fileNumber" label="档案号" width="180">
        </el-table-column>
        <el-table-column prop="memberName" label="姓名" width="180">
        </el-table-column>
        <el-table-column prop="memberSex" label="性别"> </el-table-column>
        <el-table-column prop="memberAge" label="年龄"> </el-table-column>
        <el-table-column prop="doctor" label="健康管理师"> </el-table-column>
        <el-table-column prop="memberPhone" label="手机号码"> </el-table-column>
        <el-table-column prop="memberCreated" label="注册时间">
        </el-table-column>
        <el-table-column fixed="right" label="操作" width="200">
          <template slot-scope="scope">
             <el-button size="mini" plain @click="handleClick(scope.row)">上传报告</el-button>
            <el-button type="danger" size="mini" plain @click="delitClcik(scope.row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </template>
    <!-- 分页 -->
    <div class="block">
      <el-pagination style="margin-top: 30px" @size-change="handleSizeChange" @current-change="handleCurrentChange"
        :current-page="currentPage" :page-sizes="[5, 5, 10, totalNum]" :page-size="100"
        layout="->,total, sizes, prev, pager, next, jumper" :total="totalNum">
      </el-pagination>
    </div>
    <!-- 新增模态框 -->
    <div>
      <el-dialog title="新增" :visible.sync="dialogTableVisible">
        <el-form :rules="rules" ref="formItemName" :inline="true" :model="formInline" class="demo-form-inline"
          :header-cell-style="{ background: 'black' }">
          <!-- 模态框面包屑 -->
          <el-tabs type="border-card">
            <el-tab-pane label="基本信息">
              <el-form-item label="档案号" prop="fileNumber" label-width="150px">
                <el-input v-model="formInline.fileNumber"></el-input>
              </el-form-item>
              <el-form-item prop="card" label="身份证" label-width="150px">
                <el-input v-model="formInline.memberId"></el-input>
              </el-form-item>
              <el-form-item prop="memberPassword" label="登录密码" label-width="150px">
                <el-input v-model="formInline.memberPassword"></el-input>
              </el-form-item>
              <el-form-item prop="memberPhone" label="手机号" label-width="150px">
                <el-input v-model="formInline.memberPhone"></el-input>
              </el-form-item>
              <el-form-item prop="memberName" label="姓名" label-width="150px">
                <el-input v-model="formInline.memberName"></el-input>
              </el-form-item>
              <el-form-item prop="memberSex" label="性别" label-width="140px">
                <el-select v-model="formInline.memberSex">
                  <el-option label="男" value="男"></el-option>
                  <el-option label="女" value="女"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item prop="national" label="名族" label-width="150px">
                <el-input v-model="formInline.member_minority"></el-input>
              </el-form-item>
              <el-form-item prop="memberAge" label="年龄" label-width="150px">
                <el-input v-model="formInline.memberAge"></el-input>
              </el-form-item>
              <el-form-item prop="fileNumber" label="出生日期" label-width="140px">
                <template>
                  <el-date-picker v-model="formInline.memberBirth" type="date" placeholder="选择日期">
                  </el-date-picker>
                </template>
              </el-form-item>
              <el-form-item prop="emali" label="邮箱" label-width="150px">
                <el-input v-model="formInline.member_email"></el-input>
              </el-form-item>
              <el-form-item prop="marr" label="婚姻状态" label-width="150px">
                <el-input v-model="formInline.memberMarriage"></el-input>
              </el-form-item>
              <el-form-item prop="work" label="职业" label-width="150px">
                <el-input v-model="formInline.memberCareer"></el-input>
              </el-form-item>
              <el-form-item prop="culture" label="文化程度" label-width="150px">
                <el-input v-model="formInline.memberEdu"></el-input>
              </el-form-item>
              <el-form-item prop="adresss" label="籍贯" label-width="150px">
                <el-input v-model="formInline.memberOrigin"></el-input>
              </el-form-item>
              <el-form-item prop="doctor" label="健康管理师" label-width="150px">
                <el-input v-model="formInline.doctor"></el-input>
              </el-form-item>
              <el-form-item prop="state" label="档案状态" label-width="150px">
                <el-select v-model="formInline.classfication" placeholder="启用">
                  <el-option label="启用" value="1"></el-option>
                  <el-option label="禁用" value="0"></el-option>
                </el-select>
              </el-form-item>
              <el-row :span="10" label>
                <el-form-item prop="desc" label="备注" class="textareas">
                  <el-input :autosize="{ minRows: 2, maxRows: 4 }" type="textarea"
                    v-model="formInline.memberDescription"></el-input>
                </el-form-item>
              </el-row>
            </el-tab-pane>
            <!-- 动态信息 -->
            <el-tab-pane label="动态信息">
              <el-row>
                <el-col :span="6">
                  <el-form-item prop="manheight" label="身高">
                    <el-input v-model="formInline.memberHeight" size="mini" style="width: 80px"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item prop="weigt" label="体重">
                    <el-input v-model="formInline.memberWeight" size="mini" style="width: 80px"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item prop="bloodpressure" label="舒张压">
                    <el-input v-model="formInline.shuzhangya" size="mini" style="width: 80px"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item prop="lowblood" label="收缩压">
                    <el-input v-model="formInline.shousuoya" size="mini" style="width: 80px"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item prop="breathing" label="呼吸">
                    <el-input v-model="formInline.breathe" size="mini"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item prop="temperature" label="体温">
                    <el-input v-model="formInline.memberTemperature" size="mini"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item prop="waist" label="腰围">
                    <el-input v-model="formInline.yaowei" size="mini"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item prop="hip " label="臀围">
                    <el-input v-model="formInline.tunwei" size="mini"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item prop="bmi" label="BMI">
                    <el-input v-model="formInline.BMI" size="mini"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item prop="bloodlevel" label="血氧饱和度">
                    <el-input v-model="formInline.baohedu" size="mini" style="width: 80px"></el-input>
                    %
                  </el-form-item>
                </el-col>
              </el-row>
            </el-tab-pane>
            <!-- 病史部分 -->
            <el-tab-pane label="病史">
              <el-row>
                <el-col :span="24">
                  <el-form-item label="既往史">
                    <el-input type="textarea" v-model="formInline.jiwangshi"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <el-form-item label="家族史">
                    <el-input type="textarea" v-model="formInline.jiazushi"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <el-form-item label="过敏史">
                    <el-input type="textarea" v-model="formInline.guominshi"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <el-form-item label="病史">
                    <el-input type="textarea" v-model="formInline.bingshi"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <el-form-item label="慢性病">
                    <el-input type="textarea" v-model="formInline.manxingbing"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-tab-pane>
          </el-tabs>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="submitForm(formInline)" type="primary">保存</el-button>
          <el-button @click="dialogTableVisible = false">取消</el-button>
        </div>
      </el-dialog>
    </div>

    <!-- 编辑模态框 -->
    <div>
      <el-dialog title="新增" :visible.sync="dialogTableVisible1">
        <el-form :rules="rules" ref="formItemName" :inline="true" :model="formInline_a" class="demo-form-inline"
          :header-cell-style="{ background: 'black' }">
          <!-- 模态框面包屑 -->
          <el-tabs type="border-card">
            <el-tab-pane label="基本信息">
              <el-form-item label="档案号" prop="fileNumber" label-width="150px">
                <el-input v-model="formInline_a.fileNumber"></el-input>
              </el-form-item>
              <el-form-item prop="memberId " label="身份证" label-width="150px">
                <el-input v-model="formInline_a.memberId"></el-input>
              </el-form-item>
              <el-form-item prop="memberPassword" label="登录密码" label-width="150px">
                <el-input v-model="formInline_a.memberPassword"></el-input>
              </el-form-item>
              <el-form-item prop="memberPhone" label="手机号" label-width="150px">
                <el-input v-model="formInline_a.memberPhone"></el-input>
              </el-form-item>
              <el-form-item prop="memberName" label="姓名" label-width="150px">
                <el-input v-model="formInline_a.memberName"></el-input>
              </el-form-item>
              <el-form-item prop="memberSex" label="性别" label-width="140px">
                <el-select v-model="formInline_a.memberSex">
                  <el-option label="男" value="男"></el-option>
                  <el-option label="女" value="女"></el-option>
                </el-select>
              </el-form-item>
              <el-form-item prop="member_minority  " label="名族" label-width="150px">
                <el-input v-model="formInline_a.member_minority"></el-input>
              </el-form-item>
              <el-form-item prop="memberAge" label="年龄" label-width="150px">
                <el-input v-model="formInline_a.memberAge"></el-input>
              </el-form-item>
              <el-form-item prop="memberBirth" label="出生日期" label-width="140px">
                <template>
                  <el-date-picker v-model="formInline_a.memberBirth" type="date" placeholder="选择日期">
                  </el-date-picker>
                </template>
              </el-form-item>
              <el-form-item prop="member_email" label="邮箱" label-width="150px">
                <el-input v-model="formInline_a.member_email"></el-input>
              </el-form-item>
              <el-form-item prop="memberMarriage" label="婚姻状态" label-width="150px">
                <el-input v-model="formInline_a.memberMarriage"></el-input>
              </el-form-item>
              <el-form-item prop="memberCareer  " label="职业" label-width="150px">
                <el-input v-model="formInline_a.memberCareer"></el-input>
              </el-form-item>
              <el-form-item prop="memberEdu  " label="文化程度" label-width="150px">
                <el-input v-model="formInline_a.memberEdu"></el-input>
              </el-form-item>
              <el-form-item prop="memberOrigin  " label="籍贯" label-width="150px">
                <el-input v-model="formInline_a.memberOrigin"></el-input>
              </el-form-item>
              <el-form-item prop="doctor" label="健康管理师" label-width="150px">
                <el-input v-model="formInline_a.doctor"></el-input>
              </el-form-item>
              <el-form-item prop="classfication  " label="档案状态" label-width="150px">
                <el-select v-model="formInline_a.classfication" placeholder="启用">
                  <el-option label="启用" value="1"></el-option>
                  <el-option label="禁用" value="0"></el-option>
                </el-select>
              </el-form-item>
              <el-row :span="10" label>
                <el-form-item prop="memberDescription   " label="备注" class="textareas">
                  <el-input :autosize="{ minRows: 2, maxRows: 4 }" type="textarea"
                    v-model="formInline_a.memberDescription"></el-input>
                </el-form-item>
              </el-row>
            </el-tab-pane>
            <!-- 动态信息 -->
            <el-tab-pane label="动态信息">
              <el-row>
                <el-col :span="6">
                  <el-form-item prop="memberHeight  " label="身高">
                    <el-input v-model="formInline_a.memberHeight" size="mini" style="width: 80px"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item prop="memberWeight  " label="体重">
                    <el-input v-model="formInline_a.memberWeight" size="mini" style="width: 80px"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item prop="shuzhangya  " label="舒张压">
                    <el-input v-model="formInline_a.shuzhangya" size="mini" style="width: 80px"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="6">
                  <el-form-item prop="shousuoya  " label="收缩压">
                    <el-input v-model="formInline_a.shousuoya" size="mini" style="width: 80px"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item prop="breathe    " label="呼吸">
                    <el-input v-model="formInline_a.breathe" size="mini"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item prop="memberTemperature   " label="体温">
                    <el-input v-model="formInline_a.memberTemperature" size="mini"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item prop="yaowei    " label="腰围">
                    <el-input v-model="formInline_a.yaowei" size="mini"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item prop="tunwei    " label="臀围">
                    <el-input v-model="formInline_a.tunwei" size="mini"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item prop="BMI" label="BMI">
                    <el-input v-model="formInline_a.bmi" size="mini"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item prop="baohedu   " label="血氧饱和度">
                    <el-input v-model="formInline_a.baohedu" size="mini" style="width: 80px"></el-input>
                    %
                  </el-form-item>
                </el-col>
              </el-row>
            </el-tab-pane>
            <!-- 病史部分 -->
            <el-tab-pane label="病史">
              <el-row>
                <el-col :span="24">
                  <el-form-item label="既往史">
                    <el-input type="textarea" v-model="formInline_a.jiwangshi"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <el-form-item label="家族史">
                    <el-input type="textarea" v-model="formInline_a.jiazushi"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <el-form-item label="过敏史">
                    <el-input type="textarea" v-model="formInline_a.guominshi"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <el-form-item label="病史">
                    <el-input type="textarea" v-model="formInline_a.bingshi"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <el-form-item label="慢性病">
                    <el-input type="textarea" v-model="formInline_a.manxingbing"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-tab-pane>
          </el-tabs>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="submitForm1(formInline_a)" type="primary">保存</el-button>
          <el-button @click="dialogTableVisible1 = false">取消</el-button>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import { time } from "../../utli/commin.js";

export default {
  data() {
    return {
      // 复选框的id
      rowId: "",
      deleteRowIdArray: [],
      // 复选框状态
      checked: true,
      // 模态框

      dialogTableVisible: false,

      formInline: {
        memberCreated: "",
        fileNumber: "", //文档编号
        memberName: "", // 姓名
        memberSex: "", //  性别
        memberAge: "", // 年龄
        docter: "", //  健康师
        memberPhone: "", // 电话号码
        memberId: "", // 身份证号
        memberPassword: "", //  密码
        member_minority: "", //  民族
        memberBirth: "", //  出生日期
        member_email: "", //   邮箱
        memberMarriage: "", //  婚姻状况
        memberCareer: "", //  职业
        memberEdu: "", //  教育程度
        memberOrigin: "", //  籍贯
        memberDescription: "", //   备注
        memberHeight: "", //  身高
        memberWeight: "", //  体重
        shuzhangya: "", //  舒张压
        shousuoya: "", //  收缩压
        breathe: "", //    呼吸
        memberTemperature: "", //   体温
        yaowei: "", //    腰围
        tunwei: "", //   臀围
        BMI: "", //    BMI
        baohedu: "", //   饱和度
        jiwangshi: "", //   既往史
        jiazushi: "", //   家族史
        guominshi: "", //   过敏史
        bingshi: "", //  病史
        manxingbing: "", //   慢性病
        classfication: "", //  0或者1  不用管
      },
      // 编辑模态框
      // formLabelWidth: "120px",
      dialogTableVisible1: false,

      formInline_a: {
        fileNumber: "", //文档编号
        memberName: "", // 姓名
        memberSex: "", //  性别
        memberAge: "", // 年龄
        docter: "", //  健康师
        memberPhone: "", // 电话号码
        memberId: "", // 身份证号
        memberPassword: "", //  密码
        member_minority: "", //  民族
        memberBirth: "", //  出生日期
        member_email: "", //   邮箱
        memberMarriage: "", //  婚姻状况
        memberCareer: "", //  职业
        memberEdu: "", //  教育程度
        memberOrigin: "", //  籍贯
        memberDescription: "", //   备注
        memberHeight: "", //  身高
        memberWeight: "", //  体重
        shuzhangya: "", //  舒张压
        shousuoya: "", //  收缩压
        breathe: "", //    呼吸
        memberTemperature: "", //   体温
        yaowei: "", //    腰围
        tunwei: "", //   臀围
        BMI: "", //    BMI
        baohedu: "", //   饱和度
        jiwangshi: "", //   既往史
        jiazushi: "", //   家族史
        guominshi: "", //   过敏史
        bingshi: "", //  病史
        manxingbing: "", //   慢性病
        classfication: "", //  0或者1  不用管
      },
      rules: {
        memberPassword: [
          { required: true, message: "请输入密码", trigger: "blur" },
          { min: 3, max: 15, message: "长度在 3个到15个字符", trigger: "blur" },
        ],
        fileNumber: [
          { required: true, message: "请输入档案号", trigger: "blur" },
        ],

        memberName: [
          { required: true, message: "请输入姓名", trigger: "blur" },
          { min: 2, max: 10, message: "长度在 3个到10个字符", trigger: "blur" },
        ],
        memberSex: [{ required: true, message: "请输入性别", trigger: "blur" }],
        memberAge: [{ required: true, message: "请输入年龄", trigger: "blur" }],
      },

      listSearch: [],
      iputnum: {
        fileNumber: "",
        memberName: "",
        memberPhone: "",
      },

      //数据
      tableData: [
        // {
        //   filenumber: "0014568",
        //   name: "王小虎",
        //   sex: "男",
        //   age: "25",
        //   healthManager: "张三",
        //   tel: "13825893698",
        //   registrationTime: "2015-04-06 10:06:25",
        // },
        // {
        //   filenumber: "0014569",
        //   name: "阿三",
        //   sex: "男",
        //   age: "25",
        //   healthManager: "李四",
        //   tel: "13825897412",
        //   registrationTime: "2016-07-06 10:06:25",
        // },
        // {
        //   filenumber: "0014570",
        //   name: "阿西吧",
        //   sex: "男",
        //   age: "25",
        //   healthManager: "赵武",
        //   tel: "13825825840",
        //   registrationTime: "2017-07-06 10:06:25",
        // },
        // {
        //   filenumber: "0014570",
        //   name: "阿西吧",
        //   sex: "男",
        //   age: "25",
        //   healthManager: "赵武",
        //   tel: "13825825840",
        //   registrationTime: "2017-07-06 10:06:25",
        // },
        // {
        //   filenumber: "0014570",
        //   name: "阿西吧",
        //   sex: "男",
        //   age: "25",
        //   healthManager: "赵武",
        //   tel: "13825825840",
        //   registrationTime: "2017-07-06 10:06:25",
        // },
        // {
        //   filenumber: "0014570",
        //   name: "阿西吧",
        //   sex: "男",
        //   age: "25",
        //   healthManager: "赵武",
        //   tel: "13825825840",
        //   registrationTime: "2017-07-06 10:06:25",
        // },
        // {
        //   filenumber: "0014570",
        //   name: "阿西吧",
        //   sex: "男",
        //   age: "25",
        //   healthManager: "赵武",
        //   tel: "13825825840",
        //   registrationTime: "20-07-06 10:06:25",
        // },
      ],
      currentPage: 1, //默认显示第一页
      pageSize: 5, //默认每页显示10条
      totalNum: 1000, //总页数
    };
  },
  created() {
    // 请求后端数据
    this.$axios({
      url: "/memberManager/memberList",
      method: "post",
      data: {},
    }).then((res) => {
      this.tableData = res.data;
      // //console.log(res.data);
      // //console.log("总数：" + res.data.length);
      // //console.log("返回值" + this.tableData);
      // 遍历数组
      this.tableData.forEach((item, index, arrr) => {
        item.memberCreated = time(item.memberCreated);
      });

      // //console.log(this.tableData);
      this.totalNum = this.tableData.length;
      this.$store.commit("UPdataSum", this.tableData.length);
    });
  },

  methods: {
    // 表格复选框事件

    selectionRow(selection, row) {
      this.rowId = row.id;
    },

    //条件查询
    searchBtn(iputnum) {
      // //console.log("输入内容", iputnum); //一个对象集合
      if (
        iputnum.memberPhone.trim() === "" &&
        iputnum.fileNumber.trim() === "" &&
        iputnum.memberName.trim() === ""
      ) {
        this.$message({ message: "请输入要查询的内容", type: "error" });
        setInterval(() => {
          location.reload();
        }, 5000);
      }

      if (iputnum.fileNumber.trim()) {
        // //console.log(iputnum);
        //发起请求传数据
        this.$axios({
          url: "/memberManager/findMemberByFileNumber",
          method: "post",
          data: iputnum,
        }).then((res) => {
          // //console.log(res.data); //错误结果没有筛选
          this.tableData = res.data;
          if (this.tableData.length === 0) {
            this.$message({
              message: "没有查询到相关信息",
              type: "warning",
            });
            location.reload();
          }
        });
      } else if (iputnum.memberName.trim()) {
        // 发起按照姓名搜索的请求
        this.$axios({
          url: "/memberManager/findMemberByMemberName",
          method: "post",
          data: iputnum,
        }).then((res) => {
          //console.log(res.data); //还是返回全部对象
          this.tableData = res.data;
          if (this.tableData.length === 0) {
            this.$message({
              message: "没有查询到相关信息",
              type: "warning",
            });
            location.reload();
          }
        });
      } else if (iputnum.memberPhone.trim()) {
        // 根据手机号发起axios请求
        this.$axios({
          url: "/memberManager/findMemberByPhone",
          method: "post",
          data: iputnum,
        }).then((res) => {
          // //console.log(res.data);
          this.tableData = res.data;
          if (this.tableData.length === 0) {
            this.$message({
              message: "没有查询到相关信息",
              type: "warning",
            });
            location.reload();
          }
        });
      } else {
        // 请求后端数据
        this.$axios({
          url: "/memberManager/memberList",
          method: "post",
          data: {
            limit: 5,
            page: 1,
          },
        }).then((res) => {
          // //console.log(res.data);
          this.tableData = res.data;
          // //console.log(this.tableData);
          this.totalNum = this.tableData.length;
        });
      }
    },

    handleSizeChange(val) {
      // //console.log(`每页 ${val} 条`);
      this.pageSize = val;
    },
    handleCurrentChange(val) {
      // //console.log(`当前页: ${val}`);
      this.currentPage = val;
    },
    // 新增模态框的表单验证
    submitForm(form) {
      //console.log(form);
      this.$refs.formItemName.validate((valid) => {
        if (valid) {
          // 发起axios请求

          this.$axios({
            url: "/memberManager/insertMember",
            method: "post",
            data: form,
            // data: JSON.stringify(form),
          }).then((res) => {
            if (res.code === 0) {
              this.$message({ message: "添加成功", type: "success" });
              this.$router.go(0);
            } else {
              this.$message({ message: "添加失败", type: "warning" });
            }
          });

          this.dialogTableVisible1 = false;
        } else {
          return false;
        }
      });
    },
    //编辑的模态框
    handleClick(row) {
      // //console.log(row);
      var id = row.id;
      this.dialogTableVisible1 = true;
      this.formInline_a.id = id;
      this.formInline_a.fileNumber = row.fileNumber;
      this.formInline_a.memberPassword = row.memberPassword;
      this.formInline_a.memberName = row.memberName;
      this.formInline_a.memberPhone = row.memberPhone;
      this.formInline_a.memberSex = row.memberSex;
      this.formInline_a.memberAge = row.memberAge;

      this.formInline_a.doctor = row.doctor;
    },
    //youwenti
    submitForm1(form) {
      //console.log(form);
      this.$refs.formItemName.validate((valid) => {
        if (valid) {
          // 发起axios请求
          this.$axios({
            url: "/memberManager/updateMember",
            method: "post",
            data: form,
          }).then((res) => {
            // //console.log(res);
            if (res.code === 0) {
              this.$message({
                message: "修改成功",
                type: "success",
              });
              this.dialogTableVisible1 = false;
              // 强制刷新页面
              location.reload();
            } else {
              this.$message({
                message: "修改失败",
                type: "warning",
              });
            }
          });
        } else {
          this.$message({
            message: "请输入正确格式",
            type: "warning",
          });
          return false;
        }
      });
    },
    //删除*
    delitClcik(n) {
      // //console.log(n);
      var id = n.id;
      if (this.rowId === id) {
        // 发起axios请求
        this.$axios({
          url: "/memberManager/deleteMemberById",
          method: "post",
          data: {
            id: id,
          },
        }).then((res) => {
          // //console.log(id);
          // //console.log(this.tableData); //41个
          //console.log(res);
          if (res.code === 0) {
            // 重新请求后台接口
            this.$axios({
              url: "/memberManager/memberList",
              method: "post",
              data: {
                limit: 5,
                page: 1,
              },
            }).then((res) => {
              // //console.log(res.data);
              this.tableData = res.data;
              // //console.log(this.tableData);
              this.totalNum = this.tableData.length;
            });
            this.$message({
              message: "删除成功",
              type: "success",
            });
          } else {
            this.$message({
              message: "删除失败",
              type: "error",
            });
          }
        });
      } else {
        this.$message({
          message: "请选中需要删除项",
          type: "error",
        });
      }
    },
  },
};
</script>

<style scoped>
.profile-top {
  overflow: hidden;
}

.input-search {
  width: 200px;
  float: left;
  margin-right: 50px;
}

.search-btn {
  float: left;
  margin-bottom: 10px;
  width: 120px;
}

/* 分页 */
.block {
  text-align: center;
}

.textareas {
  display: block;
  text-align: center;
  width: 90% !important;
}
</style>